package com.example.glgk.optionenum;


import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author lxk
 */

@Getter
@AllArgsConstructor
public enum ProcessStatus implements OptionsEnum{
    DEFT("DEFT","草稿"),
    PROCESSING("PROCESSING","审批中"),
    CANCEL("CANCEL","撤销"),
    PROCESSED("PROCESSED","已审批"),
    REJECT("REJECT","驳回");
    private String value;
    private String text;
    private Integer order;

    ProcessStatus(String value, String text) {
        this.value = value;
        this.text = text;
        // 未指定顺序就排在最后
        order = Integer.MAX_VALUE;
    }

    public static ProcessStatus getEnumByText(String text) {
        ProcessStatus[] arr = values();
        int len = arr.length;

        for (int i = 0; i < len; ++i) {
            ProcessStatus simpleEnum = arr[i];
            if (simpleEnum.getText().equals(text)) {
                return simpleEnum;
            }
        }
        return null;
    }

    public static ProcessStatus getEnumByValue(String value) {
        ProcessStatus[] arr = values();
        int len = arr.length;

        for (int i = 0; i < len; ++i) {
            ProcessStatus simpleEnum = arr[i];
            if (simpleEnum.getValue().equals(value)) {
                return simpleEnum;
            }
        }
        return null;
    }

}
